package com.happyfamily.springboot.crowdsourcingplatform.service.sun.impl;

import com.happyfamily.springboot.crowdsourcingplatform.dao.sun.NewDao;
import com.happyfamily.springboot.crowdsourcingplatform.model.News;
import com.happyfamily.springboot.crowdsourcingplatform.service.sun.NewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class NewServiceImpl implements NewService
{
	@Autowired(required = false)
	private NewDao newDao;

	@Override
	public List<News> getList(String uaccount, Integer limit, Integer end)
	{
		return newDao.getList(uaccount,limit,limit*(end-1));
	}

	@Override
	public int getSum(String uaccount)
	{
		return newDao.getSum(uaccount);
	}

	@Override
	public boolean addNews(News news)
	{
		boolean flag=false;
		int n=newDao.addNews(news);
		if(n>0)
		{
			flag=true;
		}
		return flag;
	}

	@Override
	public boolean deleteNews(Long nid)
	{
		boolean flag=false;
		int n=newDao.deleteNews(nid);
		if(n>0)
		{
			flag=true;
		}
		return flag;
	}
}